// vite.config.js
import { resolve } from 'path'
import { defineConfig } from 'vite'

export default defineConfig({
  publicDir: '',
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points
      entry: resolve(__dirname, 'src/index.js'),
      name: 'XMindViewer',
      // the proper extensions will be added
      fileName: 'xmind-viewer',
    },
    rollupOptions: {
      // 确保外部化处理那些你不想打包进库的依赖
      external: ['jszip', 'xml-js', '@antv/g6'],
      output: {
        // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
        globals: {
          jszip: 'JSZip',
          'xml-js': 'XmlJs',
          '@antv/g6': 'G6'
        },
      },
    },
  },
})
